home *** CD-ROM | disk | FTP | other *** search
- /* This script will back up my 5 source code directories to a floppy disk.
- I keep the source code for MegaD in MD: MDP: COM: SP: and RX:.
- If you should want to use this script to backup a directory you should
- change the directory names to something more useful. The script expect
- a blank disk or a disk that has only been used by this script.
- Do not create your own directory on this disk or the script will fail.
- */
-
- lhaFileName = "odds&ends:commands/lha"
- options results
- signal on syntax
- if ~show("L","rexxsupport.library") then call addlib"rexxsupport.library",0,-30
-
- address MEGAD
- dbug TRUE
- freevolumes /* clear out the directory buffers and close directory windows */
-
- /* be sure that the sort is on Name */
- "MenuCheck 'show,sort on,name' Check"
-
- diskin /* wait for a disk to be inserted into a drive. The script expect DF0: */
- if result = "ABORT" then exit /* user closed window */
-
- "Mark DF0:" /* Load the disk in drive DF0: and keep track of it for ARexx calls */
- if result == "" then exit /* the root disk directory did not load */
- volumename = result /* keep track of the real volume name */
- dest TRUE /* Select the Dest gadget of the Marked window */
- dirname = date(s) /* get the current date from ARexx to use as a directory name */
- unselectItem "'"dirname"'" /* check for directory with this name */
- if result ~= "" then do /* The directory already exsist */
- say dirname "exist, can not create directory"
- exit 0
- end
-
- /* before we add this directory lets find out what the last date was */
- selDir /* select all directories in all open directory windows */
- lastdir = ""
- do forever
- nextItem name clear /* get the next selected item and unselect it */
- if result = "" then leave /* no more selected directories */
- lastdir = result /* Save the last directory name */
- end
-
- if lastdir ~= "" then do /* The name of the directory are sorted dates */
- lastdir = right(lastdir,8) /* grab the last 8 characters of the directory name */
- year = substr(lastdir,3,2) /* Pull the pieces out of the name to make */
- month = substr(lastdir,5,2) /* a date filter */
- day = substr(lastdir,7,2)
- end
-
- CreateDir "'"dirname"'" /* create a directory with the sorted date string */
-
- child "'"dirname"'" /* move to child */
- dirname = insert(volumename,dirname)
- mark "'"dirname"'" /* mark the child directory */
- lock TRUE /* lock the window so we can't lose it,
- it is still set as "Dest" */
-
- /* set up the patterns for selecting files */
- FreePattern /* start with a blank list */
- AddPattern name in md#?.c
- AddPattern name in md#?.h
- AddPattern name in #?.lnk
- AddPattern name in #?.rexx
- AddPattern name in smakefile
- AddPattern name out #?protos.h /* Please note: You may create as many filters
- as you wish with ARexx */
-
- /* if lastdir is not "" then we have already backed up to this disk
- I usually back up everything to the first directory of the new backup disk
- then each future backup is only of the files changed since the first backup
- This way I can recover from one disk and usually have 5 or 6 backup on one disk
- */
- if lastdir ~= "" then do
- /* we need to move the last sorted directory string around into a
- date filter which is the opposite format */
- string = insert('-',day) /* add '-' to define Less Than date */
- string = insert(string,'-')
- string = insert(string,month)
- string = insert(string,'-')
- string = insert(string,year) /* by now the string should look like -18-12-99 */
- AddPattern date out string
- /* another note about patterns and ARexx. At this point we have a total of
- 7 filters, 5 IN type, 2 OUT type, 6 are name filters,
- one is a date filter. There is one that will select only the "smakefile"
- should one exist. There are no limits to the number of Filters you
- wish to use with ARexx.
- */
- end
-
-
-
- /* Back up assign directories */
- arguments = "md mdp com rx sp"
- do while arguments ~= ""
- PARSE VAR arguments filename arguments /* pull one of the arguments */
- filename = STRIP(filename) /* strip the spaces */
- arguments = STRIP(arguments)
- assign = insert(filename,':') /* add the ':' for the assigned name */
- mark assign /* Open and Mark the Assigned directory */
- UsePattern select /* use all of the patterns to select items
- in the open directory window */
- sourcebytes /* get how many bytes were selected */
- bytes = result
- if bytes ~= 0 then do /* files were selected by the filters */
- /* create a special User gadget to call */
- /* A special "Flags to add after Program Name" field to create the .lha flagname
- this will create a string that looks somewhat like this:
- 'a "df0:19921218/md"'
- */
- flagname = insert(dirname,'/')
- flagname = insert(flagname,filename)
- string = insert("a ",'"'flagname'"')
- string = insert("UserGadget combineAll MDscreen Execute LHAPACK odds&ends:commands/lha ","'"string"'");
- string = insert(string," NULL NULL NULL NULL NULL NULL NULL NULL");
- addproctrl string /* this creates LHAPACK */
-
- LHAPACK /* Call the program control we have just added */
- delproCtrl LHAPACK /* remove this Program Control */
-
- bytes = bytes%110
- Call delay(bytes)/* LHA packs 110 bytes to a floppy per tick (1/50 sec) */
- /* or 420 bytes to the ram disk on an A3000/25 */
- /* This was added to prevent multiple LHA running trying */
- /* to write to one floppy at one time.*/
- end
- CloseMark /* close the Marked directory */
- end
-
- UpdateDir /* update the current Dest directory */
- exit 0
-
- syntax:
- if(rc ~= 0) then do
- say "at syntax"
- say "rc = " rc
- end
- exit 0
-
-